<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
use common\models\Fenhui\Fenhui;
/* @var $this yii\web\View */
/* @var $searchModel common\models\member\MemberSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', '分会列表');
$this->params['breadcrumbs'][] = $this->title;
?>
<?php $this->beginBlock('siderbar'); ?>
<?= $this->render('//layouts/fenhui-menu') ?>
<?php $this->endBlock(); ?>
<div class="fenhui-index">

    <p>

        <button class="btn btn-success" id="start" type="button">审核</button>
        <button class="btn btn-warning" id="stop" type="button">驳回</button>
    </p>

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
    <?= GridView::widget([
        'id' => "myform",
        'pjax'=>true,
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'containerOptions'=>['style'=>'overflow: auto'], // only set when $responsive = false
        'headerRowOptions'=>['class'=>'kartik-sheet-style'],
        'filterRowOptions'=>['class'=>'filters'],
        'panel'=>[
            'heading'=>'<h3 class="panel-title"><i class="glyphicon glyphicon-globe"></i> 数据列表</h3>',
            'type'=>'default',
            'footer'=>false
        ],
        'toolbar' => [],
        'pager'=>[
            'options'=>['class'=>'hidden']//关闭自带分页
        ],
        'persistResize'=>false,

        'columns' => [
            [
                'class'=>'kartik\grid\CheckboxColumn',
                'headerOptions'=>['class'=>'my-table'],
            ],
            'id',
            'contact',
            'tel',
            'mobile',
            'fax',
            //'qiyewangzhi',
            // 'email:email',
            // 'qiyerenshu',
            // 'shigongzizhi',
            // 'certificatenumber',
            // 'zhucezijin',
            // 'konggugudong',
            // 'qiyepinpai',
            // 'jingjileixing',
            // 'qiyexingzhi',
            // 'product',
            // 'qiyejianjie',
            // 'flag',
            [
                'attribute' => 'created_at',
                'format' => ['date', 'Y-M-d H:i:s'],
            ],
            [
                'attribute' => 'updated_at',
                'format' => ['date', 'Y-M-d H:i:s'],
            ],

            [
                'attribute' => 'flag',
                'format' => 'html',
                'value' => function ($model) {
                    if ($model->flag === $model::STATUS_SUCCESS) {
                        $class = 'label-success';
                    } elseif ($model->flag === $model::STATUS_ACTIVE) {
                        $class = 'label-warning';
                    } else {
                        $class = 'label-danger';
                    }

                    return '<span class="label ' . $class . '">' . $model->statusLabel . '</span>';
                },
                'filterType'=>GridView::FILTER_SELECT2,
                'filter'=>Fenhui::getArrayStatus(),
                'filterWidgetOptions'=>[
                    'pluginOptions'=>['allowClear'=>true],
                ],
                'filterInputOptions'=>['placeholder'=>'全部'],
                'format'=>'raw'

            ],
            [
                    'attribute' => 'grade',
                    'value' => function ($model) {
                        return $model->gradeLabel;
                    },
                    'filterType'=>GridView::FILTER_SELECT2,
                    'filter'=>Fenhui::getArrayGrade(),
                    'filterWidgetOptions'=>[
                        'pluginOptions'=>['allowClear'=>true],
                    ],
                    'filterInputOptions'=>['placeholder'=>'全部'],
                    'format'=>'raw'
                ],
            [
                'class' => 'yii\grid\ActionColumn',
                'header' => '操作',
                'template' => '{view}{update}{delete}',
                'headerOptions' => ['width' => '200'],
                'buttons' => [
                    'view' => function ($url, $model, $key) {
                        return  Html::a('&nbsp;&nbsp;<span class="glyphicon glyphicon-eye-open" ><span class="classformat">查看</span></span>', $url, ['title' => '查看'] ) ;
                    },
                    'update' => function ($url, $model, $key) {
                        return Html::a('&nbsp;&nbsp;<span class="glyphicon glyphicon-pencil"><span class="classformat">修改</span></span>', $url, ['title' => '修改'] ) ;
                    },
                    'delete' => function ($url, $model, $key) {
                        return Html::a('&nbsp;&nbsp;<span class="glyphicon glyphicon-trash" ><span class="classformat">删除</span></span>', $url, [
                            'title' => '删除',
                            'data'=>[
                                'confirm'=>'你确定要删除'.$model->contact.'吗？',
                                'method'=>'post'
                            ]
                        ] ) ;
                    },

                ],
            ],
        ],
    ]); ?>
    <?= \backend\components\GoLinkPager::widget([
        'pagination' => $dataProvider->pagination,
        'go' => true,
    ]); ?>


</div>
<?php $this->beginBlock('footer_scripts'); ?>
    <script>
        $(document).ready(function(){

            bindcheck("<?php echo Url::to(['fenhui/start']);?>");
            binduncheck("<?php echo Url::to(['fenhui/stop']);?>");
            binddel("<?php echo Url::to(['fenhui/alldelete']);?>");

        });
    </script>
<?php $this->endBlock(); ?>